package com.shujia.userprofile.info.natural

import com.shujia.util.{HBaseUtil, SparkRunner, SparkTool}
import org.apache.spark.sql.{DataFrame, Dataset, Row, SparkSession}

object SexUserTag extends SparkRunner {
  fieldName = "sex"

  override def fetchTgg(spark: SparkSession, ds: String): DataFrame = {

    import spark.implicits._
    import org.apache.spark.sql.functions._

    //读取hive中的表,获取用户维度表
    val userInfo: Dataset[Row] = spark
      .table("dim.dim_pub_user_info_d_f")
      .where($"ds" === ds)

    //提取标签
    userInfo.select(
      $"id",
      when($"sex" === "1", "男")
        .when($"sex" === "2", "女")
        .otherwise("未知") as "sex"
    )
  }
}
